package com.sunwayhorizo.health.platform.security.persistent;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.sunwayhorizo.health.platform.util.BeanHelper;

@Entity
@NamedQuery(name="SecurityOperation.findAll",query="select so from SecurityOperation so")
@TableGenerator(name = "SecurityOperation_IdGenerator", table = "ET_Id_Generator", pkColumnName = "pkColumn", valueColumnName = "valueColumn", pkColumnValue = "SECURITY_OPERATION_ID",allocationSize=1)
@Table(name = "SECURITY_OPERATION", schema = "ETS")
public class SecurityOperation implements java.io.Serializable {
	
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "SecurityOperation_IdGenerator")
	@Column(name = "OPERATION_ID", unique = true, nullable = false)
	private String operationId;
	
	@Column(name = "OPERATION_NAME")
	private String operationName;
	
	@Column(name = "OPERATION_CODE")
	private String operationCode;
	
	@Column(name = "REMARK")
	private String remark;
	
	@OneToMany(mappedBy = "operation",fetch = FetchType.LAZY)
	private List<SecurityPermission> permissions = new ArrayList<SecurityPermission>(
			0);

	public SecurityOperation() {
	}

	public SecurityOperation(String operationId) {
		this.operationId = operationId;
	}

	public SecurityOperation(String operationId, String operationName,
			String operationCode, String remark, List<SecurityPermission> permissions) {
		super();
		this.operationId = operationId;
		this.operationName = operationName;
		this.operationCode = operationCode;
		this.remark = remark;
		this.permissions = permissions;
	}

	public String getOperationId() {
		return this.operationId;
	}

	public void setOperationId(String operationId) {
		this.operationId = operationId;
	}

	public String getOperationName() {
		return this.operationName;
	}

	public void setOperationName(String operationName) {
		this.operationName = operationName;
	}

	public String getOperationCode() {
		return operationCode;
	}

	public void setOperationCode(String operationCode) {
		this.operationCode = operationCode;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public List<SecurityPermission> getPermissions() {
		return this.permissions;
	}

	public void setPermissions(
			List<SecurityPermission> permissions) {
		this.permissions = permissions;
	}
	
	@Override
	public String toString() {
		return BeanHelper.toString(this);
	}
}
